package com.sinoglobal.dumping.dumplingspring;

import android.util.Log;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;

import com.sinoglobal.dumping.R;
import com.sinoglobal.dumping.fragment.Dumpling_HomeFragment;
import com.sinoglobal.dumping.view.Dumpling_GridView;

/**
 * Created by KeZhuang on 2016/1/26.
 */
public abstract class AbsDumplingLayout implements DumplingObserver{
    Dumpling_HomeFragment mFragment;
    RelativeLayout mBg;
    TextView mDesc;
    Dumpling_GridView mSupport;
    private DumplingLayoutContext mLayoutContext;
    private DumplingLayoutFactory mLayoutFactory;
    public AbsDumplingLayout(Dumpling_HomeFragment fragment){
        mFragment = fragment;
        mBg = mFragment.getView(R.id.relative_chuanglian);
        mDesc = mFragment.getView(R.id.message_info);
        mSupport = mFragment.getView(R.id.gv_zanzhu);
        if(mLayoutContext==null) mLayoutContext = new DumplingLayoutContext();
        if(mLayoutFactory==null) mLayoutFactory = new DumplingLayoutFactory();

    }

    @Override
    public void update(Dumpling_HomeFragment fragment,boolean isChangeUI, boolean isVote) {
        ImageView floatDumpling = mFragment.getView(R.id.float_toupiao);
        if(isVote){
            fragment.showView(floatDumpling);
        }else{
            fragment.hideViewForGone(floatDumpling);
        }
        if(isChangeUI){
            mFragment.getActionContent();
        }else{
            mFragment.setActionUI(null);
        }
        AbsDumplingLayout layout = mLayoutFactory.getLayout(fragment,isChangeUI);
        mLayoutContext.setLayout(layout);
    }

    public abstract void operation();
}
